<!DOCTYPE html>
<html>
<head>
<title>req_assign</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<link rel="stylesheet" type="text/css"
	href="/codebase/fonts/font_roboto/roboto.css" />
<link rel="stylesheet" type="text/css" href="/codebase/dhtmlx.css" />
<script type="text/javascript" src="/codebase/dhtmlx.js" />

<script>
/*<![CDATA[*/
	var myTabbar,myForm, myEditor1,myEditor2,myForm2,form_attach;
	var dhxWins ;
	
	function doOnLoad() {
		var v=document.getElementById("assign_test_id").innerHTML;
		//alert("onload req assign");
		if (myForm) {
			myForm.unload();
			myForm = null;
		}
		myForm = new dhtmlXForm("form_req_base_info");
		//myForm.loadStruct("/common/testmanager/test_modify_detail_test_info.xml");
		myForm.loadStruct("/test/test_modify_detail_test_info_onload?test_id="+v,function(){
			var myEditor_relation_funcation = myForm.getEditor("relation_funcation");
			var myEditor_other_remark = myForm.getEditor("other_remark");
			myEditor_relation_funcation.setContentHTML("/test/test_info_page_relation_funcation?test_id="+v);
			myEditor_other_remark.setContentHTML("/test/test_info_page_other_remark?test_id="+v);	
			
		});
			
		
		myForm.attachEvent("onButtonClick",function(name){
			
			if(name=="testing_info_save_btn"){
				
				if(check_input()){
					myForm.send("/test/test_modify_detail_testing_info_save","post",callback);	
				}
						
			}
			if(name=="export_btn"){
							
				var g_test_id=myForm.getItemValue("test_id");
				window.location.href = '/ExcelGenerator_test_info_sum?test_id='+g_test_id;
			}
		});		
		
		myForm.attachEvent("onChange", function (name, value){
		     if(name == "contingency_plan"){
		    	 if(value == "无"){
		    		 myForm.setRequired("contingency_plan_remark",true);
		    		 myForm.setItemLabel("contingency_plan_remark","原因：");
		    		 myForm.enableItem("contingency_plan_remark");
		    	 }else{
		    		 if(value=="有替代交易功能或渠道"){
		    			 myForm.setRequired("contingency_plan_remark",true);
		    			 myForm.setItemLabel("contingency_plan_remark","罗列如下：");
		    			 myForm.enableItem("contingency_plan_remark");
		    		 }
		    		 else{
		    			 myForm.setRequired("contingency_plan_remark",false);
		    			 myForm.disableItem("contingency_plan_remark");
		    			 myForm.setItemValue("contingency_plan_remark","");
		    		 }
		    	 }
		     }
		});
		
		myForm.attachEvent("onValidateError", function (name, value, result){
			var tmp_label=myForm.getItemLabel(name);	
			if(tmp_label=="测试时长"){
				alert("【测试时长】字段，请输入数字,小数位只有一位，且只能为5或0! \n 录入值为"+value);
				myForm.enableItem("assign_btn1");
			}
			else{
				  alert("校验【"+tmp_label+"】 值为【"+value+ "】 ， 请更正");
				  myForm.enableItem("assign_btn1");
			}	   				
		});
	}
	
	function createWindow() {
		//alert("open_createWindow");
		var p = 0;		
		var id = "req_assign_window";
		//
		var w = 700;
		var h = 200;
		var x = 200;
		var y = 300;
		
		//
		dhxWins=new dhtmlXWindows();
		dhxWins.createWindow(id, x, y, w, h);
		dhxWins.window(id).setText("需求退回");
		
		dhxWins.window(id).denyPark();
		dhxWins.window(id).button("park").hide();
		
		dhxWins.window(id).attachURL("req_reject");
		
		
	
	}
	
	function callback(){				
		if (arguments[1]=="true"){
			alert("保存信息成功");
			//window.location.pathname="index";
		}else{
			alert("保存信息失败！callback : "+arguments[1]);
		}
	}	
	
	function check_input(){		
		var r=false;
		var g_start_date_obj=myForm.getCalendar("online_trace_start_date");
		var g_start_date=g_start_date_obj.getDate(true);
		var g_end_date_obj=myForm.getCalendar("online_trace_end_date");
		var g_end_date=g_end_date_obj.getDate(true);
		
		var date1=new Date(g_start_date);
		var date2=new Date(g_end_date);
		var result=Date.parse(date1)<Date.parse(date2); 
		var result2=Date.parse(date1)==Date.parse(date2)
		if (result||result2){
		
			r= true;
		}else{
			alert("【跟踪开始时间】"+g_start_date+"应早于【跟踪结束时间】"+g_end_date+", 请更正");
			r= false;
		}
		
		var get_workload=myForm.getItemValue("test_workload");
		if(get_workload==0){
			alert("【测试时间长】"+get_workload+"应大于0, 请更正");
			r= false;
		}
		return r;
	}	
	
	function check_workload(data) {
		//alert(data);
		//var check_value=myForm.getItemValue("req_workload");
		
		var reg = new RegExp("^[0-9]+(.[05]{1})?$");  
		data=data*1;
		var t_check_value=data.toFixed(1);
			  if(!reg.test(t_check_value)){  
			     //   alert("【需求分析工作量】字段，请输入数字,小数位只有一位，且只能为5或0!录入值为"+check_value);
			        var r=false;
			        return(r);
			    }else{
			    	return(true);
			    }
		}
	/*]]>*/
</script>
</head>
<body onload="doOnLoad();">
<div id="assign_test_id" name="assign_test_id" th:text="${test_id}" style="display: none;" > </div>
	<table>
		<tr>
			<td>
				<div id="form_req_base_info" ></div>
			</td>
		</tr>
	</table>
	
</body>
</html>